//
//  CZQHomeShareView.m
//  coachmanage
//
//  Created by 众拳科技 on 2018/3/22.
//  Copyright © 2018年 众拳科技. All rights reserved.
//

#import "CZQHomeShareView.h"

@implementation CZQHomeShareView
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        self.backgroundColor = CSWhiteColor;
        self.scrollView.showsVerticalScrollIndicator = NO;
        
        /**
         滚动
         */
        UIScrollView *scrollView = [UIScrollView new];
        [self addSubview:scrollView];
        self.scrollView = scrollView;
        
        /**
         bg图片
         */
        UIImageView *bgView = [UIImageView new];
        bgView.userInteractionEnabled = YES;
        bgView.image = [UIImage imageNamed:@"t-bg"];
        [self.scrollView addSubview:bgView];
        self.bgView = bgView;

        
        /**
         头像
         */
        UIButton *iconBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [iconBtn setImage:PlaceHold forState:UIControlStateNormal];
        iconBtn.layer.cornerRadius = 25;
        iconBtn.clipsToBounds = YES;
        [self.bgView addSubview:iconBtn];
        self.iconBtn = iconBtn;

        
        /**
         等级
         */
        UIButton *classBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        classBtn.contentEdgeInsets = UIEdgeInsetsMake(3, 10, 3, 10);
        classBtn.layer.cornerRadius = 8;
        classBtn.clipsToBounds = YES;
        [classBtn setTitle:@"p1等级"];
        classBtn.backgroundColor = CSColorFromRGB(0xbd9e64);
        [classBtn setTitleColor:CSWhiteColor];
        classBtn.titleLabel.font = SmallFont;
        [self.bgView addSubview:classBtn];
        self.classBtn = classBtn;
        
        
        /**
         教练名
         */
        UILabel *nameLable = [UILabel new];
        nameLable.text = @"陈志强";
        nameLable.font = BigFont;
        nameLable.textColor = CSWhiteColor;
        [self.bgView addSubview:nameLable];
        self.nameLable = nameLable;
        
        /**
         学员个数
         */
        UILabel *studyCountLable = [UILabel new];
        studyCountLable.text = @"已帮助41名学员塑形成功";
        studyCountLable.font = BigFont;
        studyCountLable.textColor = TextColor1;
        [self.bgView addSubview:studyCountLable];
        self.studyCountLable = studyCountLable;
        
        
        /**
         //竖线
         */
        UIView *suView = [UIView new];
        suView.backgroundColor = ButtonBackGroundColor;
        [self.scrollView addSubview:suView];
        self.suView = suView;
        
        /**
         //常去门店
         */
        UILabel *shopLable = [UILabel new];
        shopLable.text = @"常去门店";
        shopLable.font = TitleBoldFont;
        shopLable.textColor = BlackColor;
        [self.scrollView addSubview:shopLable];
        self.shopLable = shopLable;
        
        /**
         //常去门店tag
         */
        //第三方标签布局的视图
        SKTagView *tagView = [[SKTagView alloc] init];
        // 整个tagView对应其SuperView的上左下右距离
        tagView.padding = UIEdgeInsetsMake(10, 10, 10, 10);
        // 上下行之间的距离
        tagView.lineSpacing = 10;
        // item之间的距离
        tagView.interitemSpacing = 10;
        // 最大宽度
        tagView.preferredMaxLayoutWidth = kScreenWidth/2 ;
        //        tagView.regularWidth = kScreenWidth - 80;
        //    @property (assign, nonatomic) CGFloat regularWidth; //!< 固定宽度
        //    @property (nonatomic,assign ) CGFloat regularHeight; //!< 固定高度
        // 原作者没有能加固定宽度的，自己修改源码加上了固定宽度和高度,默认是0，就是标签式布局，如果实现了，那么就是固定宽度高度
        //    self.tagView.regularWidth = 100;
        //            tagView.regularHeight = 30;
        [self.scrollView addSubview:tagView];
        
        self.shopTagView = tagView;

        /**
         //竖线
         */
        UIView *suView1 = [UIView new];
        suView1.backgroundColor = ButtonBackGroundColor;
        [self.scrollView addSubview:suView1];
        self.suView1 = suView1;
        
        /**
         //擅长课程
         */
        UILabel *longLable = [UILabel new];
        longLable.text = @"擅长课程";
        longLable.font = TitleBoldFont;
        longLable.textColor = BlackColor;
        [self.scrollView addSubview:longLable];
        self.longLable = longLable;
        
        
        /**
         //擅长课程内容
         */
        UILabel *shopTitleLable = [UILabel new];
        shopTitleLable.text = @"擅长课程擅长课程擅长课程擅长课程擅长课程擅长课程擅长课程擅长课程擅长课程擅长课程擅长课程";
        shopTitleLable.font = MidBigFont;
        shopTitleLable.numberOfLines = 0;
        shopTitleLable.textColor = GrakColor;
        [self.scrollView addSubview:shopTitleLable];
        self.shopTitleLable = shopTitleLable;
        
        
        /**
         //横线
         */
        UIView *sepView = [UIView new];
        sepView.backgroundColor =BackGroundColor;
        [self.scrollView addSubview:sepView];
        self.sepView = sepView;
        
        /**
         重拳体育图片
         */
        UIImageView *logoImageView = [UIImageView new];
        logoImageView.image = [UIImage imageNamed:@"img_logo"];
        [self.scrollView addSubview:logoImageView];
        self.logoImageView = logoImageView;
        
        /**
         评语
         */
        UILabel *commentLable = [UILabel new];
        commentLable.text = @"擅长课程擅长课程擅长课程擅长课程擅长课程擅长课程擅长课程擅长课程擅长课程擅长课程擅长课程";
        commentLable.font = MidBigFont;
        commentLable.numberOfLines = 0;
        commentLable.textColor = GrakColor;
        [self.scrollView addSubview:commentLable];
        self.commentLable = commentLable;

        
        /**
         二微码
         */
        UIButton *maBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [maBtn setImage:@"img_abdominalmuscles"];
        [self.scrollView addSubview:maBtn];
        self.maBtn = maBtn;

        /**
         继续按钮
         */
        UIButton *continuBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        continuBtn.backgroundColor = ButtonBackGroundColor;
        [continuBtn setTitle:@"继续"];
        [continuBtn setTitleColor:BackGroundColor];
        [self.scrollView addSubview:continuBtn];
        self.continuBtn = continuBtn;
        
        [self setConstraints];
    }
    return self;
}

-(void)setConstraints
{
    
    /**
     滚动
     */
    [self.scrollView mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.edges.mas_equalTo(self);
        
    }];
    
    /**
     bg图片
     */
    [self.bgView mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.left.right.mas_equalTo(self);
        
    }];
    
    /**
     头像
     */
    [self.iconBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.mas_equalTo(self.bgView);
        make.top.mas_equalTo(self.bgView).offset(20);
        make.width.height.mas_equalTo(50);
        
    }];
    
    /**
     等级
     */
    [self.classBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.mas_equalTo(self.bgView);
        make.top.mas_equalTo(self.iconBtn.mas_bottom).offset(-8);
        make.height.mas_equalTo(16);
        
    }];
    
    /**
     教练名
     */
    [self.nameLable mas_remakeConstraints:^(MASConstraintMaker *make) {

        make.centerX.mas_equalTo(self.bgView);
        make.top.mas_equalTo(self.classBtn.mas_bottom).offset(10);
        make.height.mas_equalTo(25);

    }];

    
    /**
     学员个数
     */
    [self.studyCountLable mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.mas_equalTo(self.bgView);
        make.top.mas_equalTo(self.nameLable.mas_bottom).offset(10);
        make.bottom.mas_equalTo(self.bgView).offset(-15);
        make.height.mas_equalTo(25);
    }];
    
    
    /**
     //竖线
     */
    [self.suView mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.mas_equalTo(self.shopLable);
        make.left.mas_equalTo(self).offset(20);
        make.height.mas_equalTo(20);
        make.width.mas_equalTo(2);
        
    }];
    
    /**
     //常去门店
     */
    [self.shopLable mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.bgView.mas_bottom).offset(15);
        make.left.mas_equalTo(self.suView.mas_right).offset(5);
        make.height.mas_equalTo(30);
    }];
    
    /**
     //常去门店tag
     */
    [self.shopTagView mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.shopLable.mas_bottom).offset(10);
        make.left.mas_equalTo(self.suView);
        make.right.mas_equalTo(self).offset(-10);
        
    }];
    /**
     //竖线
     */
    [self.suView1 mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.mas_equalTo(self.longLable);
        make.left.mas_equalTo(self.suView);
        make.height.mas_equalTo(20);
        make.width.mas_equalTo(2);
        
    }];
    
    /**
     //擅长课程
     */
    [self.longLable mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.shopTagView.mas_bottom).offset(20);
        make.left.mas_equalTo(self.suView1.mas_right).offset(5);
        
    }];
    
    
    /**
     //擅长课程内容
     */
    [self.shopTitleLable mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.longLable.mas_bottom).offset(15);
        make.left.mas_equalTo(self.suView);
        make.right.mas_equalTo(self).offset(-10);
        
    }];

    
    
    /**
     //横线
     */
    [self.sepView mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.shopTitleLable.mas_bottom).offset(20);
        make.left.mas_equalTo(self.suView);
        make.right.mas_equalTo(self).offset(-10);
        make.height.mas_equalTo(1);
        
    }];
    
    /**
     重拳体育图片
     */
    [self.logoImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.sepView.mas_bottom).offset(20);
        make.left.mas_equalTo(self.suView);
        
    }];
    
    /**
     评语
     */
    [self.commentLable mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.logoImageView.mas_bottom).offset(10);
        make.left.mas_equalTo(self.suView);
        make.right.mas_equalTo(self.maBtn.mas_left).offset(-20);
        
    }];

    
    /**
     二微码
     */
    [self.maBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.logoImageView);
        make.right.mas_equalTo(self).offset(-20);
        make.width.height.mas_equalTo(40);
        
    }];
    
    /**
     继续按钮
     */
    [self.continuBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.commentLable.mas_bottom).offset(50);
        make.left.right.mas_equalTo(self);
        make.height.mas_equalTo(50);
        
//        make.bottom.mas_equalTo(self).offset(-50);
        
    }];

}
-(void)layoutSubviews
{
    
    self.scrollView.contentSize = CGSizeMake(0, self.continuBtn.bottom + 50);
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
